<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>springboot究竟是如何启动的？ | 是小亚呀</title><meta name="author" content="小亚"><meta name="copyright" content="小亚"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="SpringBoot是什么？简单来说：springboot是依赖于spring的，比起spring，除了拥有spring的全部功能以外，springboot无需繁琐的xml配置，这取决于它自身强大的自动装配功能；并且自身已嵌入Tomcat、Jetty等web容器，集成了springmvc，使得springboot可以直接运行，不需要额外的容器。 SpringBoot的核心功能1、 可独立运行的Sp">
<meta property="og:type" content="article">
<meta property="og:title" content="springboot究竟是如何启动的？">
<meta property="og:url" content="https://zhangyw0803.gitee.io/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/index.html">
<meta property="og:site_name" content="是小亚呀">
<meta property="og:description" content="SpringBoot是什么？简单来说：springboot是依赖于spring的，比起spring，除了拥有spring的全部功能以外，springboot无需繁琐的xml配置，这取决于它自身强大的自动装配功能；并且自身已嵌入Tomcat、Jetty等web容器，集成了springmvc，使得springboot可以直接运行，不需要额外的容器。 SpringBoot的核心功能1、 可独立运行的Sp">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://zhangyw0803.gitee.io/img/f.jpg">
<meta property="article:published_time" content="2024-06-03T05:42:42.000Z">
<meta property="article:modified_time" content="2024-06-03T07:46:21.316Z">
<meta property="article:author" content="小亚">
<meta property="article:tag" content="框架">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://zhangyw0803.gitee.io/img/f.jpg"><link rel="shortcut icon" href="/img/f.jpg"><link rel="canonical" href="https://zhangyw0803.gitee.io/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy Successful',
    error: 'Copy Error',
    noSupport: 'Browser Not Supported'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: 'Just now',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: 'Load More'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'springboot究竟是如何启动的？',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-06-03 15:46:21'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="/css/background.css"><meta name="generator" content="Hexo 7.0.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/f.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">6</div></a><a href="/tags/"><div class="headline">Tags</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">Categories</div><div class="length-num">2</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/image/image1.jpg')"><nav id="nav"><span id="blog-info"><a href="/" title="是小亚呀"><span class="site-name">是小亚呀</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">springboot究竟是如何启动的？</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2024-06-03T05:42:42.000Z" title="Created 2024-06-03 13:42:42">2024-06-03</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2024-06-03T07:46:21.316Z" title="Updated 2024-06-03 15:46:21">2024-06-03</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Spring/">Spring</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="springboot究竟是如何启动的？"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post Views:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="SpringBoot是什么？"><a href="#SpringBoot是什么？" class="headerlink" title="SpringBoot是什么？"></a>SpringBoot是什么？</h2><p>简单来说：springboot是依赖于spring的，比起spring，除了拥有spring的全部功能以外，springboot无需繁琐的xml配置，这取决于它自身强大的自动装配功能；并且自身已嵌入Tomcat、Jetty等web容器，集成了springmvc，使得springboot可以直接运行，不需要额外的容器。</p>
<h3 id="SpringBoot的核心功能"><a href="#SpringBoot的核心功能" class="headerlink" title="SpringBoot的核心功能"></a>SpringBoot的核心功能</h3><p>1、 可独立运行的Spring项目：Spring Boot可以以jar包的形式独立运行。</p>
<p>2、 内嵌的Servlet容器：Spring Boot可以选择内嵌Tomcat、Jetty或者Undertow，无须以war包形式部署项目。</p>
<p>3、 简化的Maven配置：Spring提供推荐的基础 POM 文件来简化Maven 配置。</p>
<p>4、 自动配置Spring：Spring Boot会根据项目依赖来自动配置Spring 框架，极大地减少项目要使用的配置。</p>
<p>5、 提供生产就绪型功能：提供可以直接在生产环境中使用的功能，如性能指标、应用信息和应用健康检查。</p>
<p>6、 无代码生成和xml配置：Spring Boot不生成代码。完全不需要任何xml配置即可实现Spring的所有配置。</p>
<h3 id="SpringBoot-的启动过程"><a href="#SpringBoot-的启动过程" class="headerlink" title="SpringBoot 的启动过程"></a>SpringBoot 的启动过程</h3><p><img src="/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/cad8acaf28038c21bd1ca3f5272fbf65-1717393844636.png" alt="img"></p>
<h5 id="1、运行-SpringApplication-run-方法"><a href="#1、运行-SpringApplication-run-方法" class="headerlink" title="1、运行 SpringApplication.run()方法"></a>1、运行 SpringApplication.run()方法</h5><p>所有的标准的springboot的应用程序都是从run方法开始的 ，从main 方法开始 ，运行run方法。进入run方法后，会 new 一个SpringApplication 对象，创建这个对象的构造函数做了一些准备工作</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="meta">@SpringBootApplication</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">HApplication</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        SpringApplication.run(HApplication.class, args);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 另外  SpringBootApplication注解 </span></span><br><span class="line"><span class="meta">@Target(&#123;ElementType.TYPE&#125;)</span></span><br><span class="line"><span class="meta">@Retention(RetentionPolicy.RUNTIME)</span></span><br><span class="line"><span class="meta">@Documented</span></span><br><span class="line"><span class="meta">@Inherited</span></span><br><span class="line"><span class="meta">@SpringBootConfiguration</span></span><br><span class="line"><span class="meta">@EnableAutoConfiguration</span></span><br><span class="line"><span class="meta">@ComponentScan(</span></span><br><span class="line"><span class="meta">    excludeFilters = &#123;@Filter(</span></span><br><span class="line"><span class="meta">    type = FilterType.CUSTOM,</span></span><br><span class="line"><span class="meta">    classes = &#123;TypeExcludeFilter.class&#125;</span></span><br><span class="line"><span class="meta">), @Filter(</span></span><br><span class="line"><span class="meta">    type = FilterType.CUSTOM,</span></span><br><span class="line"><span class="meta">    classes = &#123;AutoConfigurationExcludeFilter.class&#125;</span></span><br><span class="line"><span class="meta">)&#125;</span></span><br><span class="line"><span class="meta">)</span></span><br><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> SpringBootApplication &#123;</span><br><span class="line">    <span class="comment">// ...</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="2、确定应用程序类型"><a href="#2、确定应用程序类型" class="headerlink" title="2、确定应用程序类型"></a>2、确定应用程序类型</h5><p>在SpringApplication的构造方法内，首先会通过 WebApplicationType.deduceFromClasspath()； 方法判断当前应用程序的容器，默认使用的是Servlet 容器，除了servlet之外，还有NONE 和 REACTIVE （响应式编程）；<br><img src="/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/image.png" alt="Alt text"></p>
<h5 id="3、-加载所有的初始化器"><a href="#3、-加载所有的初始化器" class="headerlink" title="3、 加载所有的初始化器"></a>3、 加载所有的初始化器</h5><p>加载的初始化器是springboot自带初始化器，从从 META-INF&#x2F;spring.factories 配置文件中加载的， 自带有2个，分别在源码的jar包的 spring-boot-autoconfigure 项目 和 spring-boot 项目里面各有一个<br><img src="/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/image2.png" alt="Alt text"><br>spring.factories文件里面，看到开头是 org.springframework.context.ApplicationContextInitializer 接口就是初始化器了</p>
<h5 id="4、加载所有的监听器"><a href="#4、加载所有的监听器" class="headerlink" title="4、加载所有的监听器"></a>4、加载所有的监听器</h5><p>加载监听器也是从 <code>META-INF/spring.factories</code> 配置文件中加载的，与初始化不同的是，监听器加载的是实现了 ApplicationListener 接口的类</p>
<h5 id="5、设置程序运行的主类"><a href="#5、设置程序运行的主类" class="headerlink" title="5、设置程序运行的主类"></a>5、设置程序运行的主类</h5><p><code>deduceMainApplicationClass();</code> 这个方法仅仅是找到main方法所在的类，为后面的扫包作准备，deduce是推断的意思，所以准确地说，这个方法作用是推断出主方法所在的类；</p>
<h5 id="6、开启计时器"><a href="#6、开启计时器" class="headerlink" title="6、开启计时器"></a>6、开启计时器</h5><p>运行到run方法的主体， 调用run党法的静态方法，那个时候还没实例化SpringApplication对象，现在调用的run方法是非静态的，是需要实例化后才可以调用的，进来后首先会开启计时器， 来记录springboot启动花了多长时间</p>
<h5 id="7、将java-awt-headless设置为true"><a href="#7、将java-awt-headless设置为true" class="headerlink" title="7、将java.awt.headless设置为true"></a>7、将java.awt.headless设置为true</h5><p>这里将java.awt.headless设置为true，表示运行在服务器端，在没有显示器器和鼠标键盘的模式下照样可以工作，模拟输入输出设备功能。</p>
<p>做了这样的操作后,SpringBoot想干什么呢?其实是想设置该应用程序,即使没有检测到显示器,也允许其启动.对于服务器来说,是不需要显示器的,所以要这样设置.</p>
<h5 id="8、获取并启用监听器"><a href="#8、获取并启用监听器" class="headerlink" title="8、获取并启用监听器"></a>8、获取并启用监听器</h5><p>创建所有 Spring 运行监听器并发布应用启动事件<br>然后启动监听器</p>
<h5 id="9、设置应用程序参数"><a href="#9、设置应用程序参数" class="headerlink" title="9、设置应用程序参数"></a>9、设置应用程序参数</h5><p>将执行run方法时传入的参数封装成一个对象<br>这个参数就是main 方法的传参 </p>
<h5 id="10、准备环境变量"><a href="#10、准备环境变量" class="headerlink" title="10、准备环境变量"></a>10、准备环境变量</h5><h5 id="11、忽略bean信息"><a href="#11、忽略bean信息" class="headerlink" title="11、忽略bean信息"></a>11、忽略bean信息</h5><h5 id="12、打印banner"><a href="#12、打印banner" class="headerlink" title="12、打印banner"></a>12、打印banner</h5><h5 id="13、创建应用程序的上下文"><a href="#13、创建应用程序的上下文" class="headerlink" title="13、创建应用程序的上下文"></a>13、创建应用程序的上下文</h5><p>实例化应用程序的上下文， 调用 createApplicationContext() 方法，这里就是用反射创建对象 </p>
<p><img src="/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/image3.png" alt="Alt text"> </p>
<h5 id="14、实例化异常报告器"><a href="#14、实例化异常报告器" class="headerlink" title="14、实例化异常报告器"></a>14、实例化异常报告器</h5><h5 id="15、准备上下文环境"><a href="#15、准备上下文环境" class="headerlink" title="15、准备上下文环境"></a>15、准备上下文环境</h5><p><img src="/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/image4.png" alt="Alt text"></p>
<h5 id="16、刷新上下文"><a href="#16、刷新上下文" class="headerlink" title="16、刷新上下文"></a>16、刷新上下文</h5><p>刷新上下文已经是spring的范畴了，自动装配和启动 tomcat就是在这个方法里面完成的</p>
<h5 id="17、刷新上下文后置处理"><a href="#17、刷新上下文后置处理" class="headerlink" title="17、刷新上下文后置处理"></a>17、刷新上下文后置处理</h5><h5 id="18、结束计时器"><a href="#18、结束计时器" class="headerlink" title="18、结束计时器"></a>18、结束计时器</h5><h5 id="19、发布上下文准备就绪事件"><a href="#19、发布上下文准备就绪事件" class="headerlink" title="19、发布上下文准备就绪事件"></a>19、发布上下文准备就绪事件</h5><h5 id="20、执行自定义的run方法"><a href="#20、执行自定义的run方法" class="headerlink" title="20、执行自定义的run方法"></a>20、执行自定义的run方法</h5><p>这是一个扩展功能，callRunners(context, applicationArguments) 可以在启动完成后执行自定义的run方法；有2中方式可以实现：</p>
<p>1.实现 ApplicationRunner 接口<br>2.实现 CommandLineRunner 接口</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>Author: </span><span class="post-copyright-info"><a href="https://zhangyw0803.gitee.io">小亚</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>Link: </span><span class="post-copyright-info"><a href="https://zhangyw0803.gitee.io/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/">https://zhangyw0803.gitee.io/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E6%A1%86%E6%9E%B6/">框架</a></div><div class="post_share"><div class="social-share" data-image="/img/f.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2024/06/03/SpringAOP%E5%8E%9F%E7%90%86/" title="SpringAOP原理"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">Previous</div><div class="prev_info">SpringAOP原理</div></div></a></div><div class="next-post pull-right"><a href="/2023/11/30/IOStream/" title="IOStream"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">Next</div><div class="next_info">IOStream</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>Related Articles</span></div><div class="relatedPosts-list"><div><a href="/2024/06/03/SpringAOP%E5%8E%9F%E7%90%86/" title="SpringAOP原理"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-03</div><div class="title">SpringAOP原理</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/f.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">小亚</div><div class="author-info__description">做一个有梦想的人！</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">6</div></a><a href="/tags/"><div class="headline">Tags</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">Categories</div><div class="length-num">2</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/zhang-yaya0803"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Contents</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#SpringBoot%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="toc-number">1.</span> <span class="toc-text">SpringBoot是什么？</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#SpringBoot%E7%9A%84%E6%A0%B8%E5%BF%83%E5%8A%9F%E8%83%BD"><span class="toc-number">1.1.</span> <span class="toc-text">SpringBoot的核心功能</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SpringBoot-%E7%9A%84%E5%90%AF%E5%8A%A8%E8%BF%87%E7%A8%8B"><span class="toc-number">1.2.</span> <span class="toc-text">SpringBoot 的启动过程</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#1%E3%80%81%E8%BF%90%E8%A1%8C-SpringApplication-run-%E6%96%B9%E6%B3%95"><span class="toc-number">1.2.0.1.</span> <span class="toc-text">1、运行 SpringApplication.run()方法</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2%E3%80%81%E7%A1%AE%E5%AE%9A%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.2.0.2.</span> <span class="toc-text">2、确定应用程序类型</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3%E3%80%81-%E5%8A%A0%E8%BD%BD%E6%89%80%E6%9C%89%E7%9A%84%E5%88%9D%E5%A7%8B%E5%8C%96%E5%99%A8"><span class="toc-number">1.2.0.3.</span> <span class="toc-text">3、 加载所有的初始化器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4%E3%80%81%E5%8A%A0%E8%BD%BD%E6%89%80%E6%9C%89%E7%9A%84%E7%9B%91%E5%90%AC%E5%99%A8"><span class="toc-number">1.2.0.4.</span> <span class="toc-text">4、加载所有的监听器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#5%E3%80%81%E8%AE%BE%E7%BD%AE%E7%A8%8B%E5%BA%8F%E8%BF%90%E8%A1%8C%E7%9A%84%E4%B8%BB%E7%B1%BB"><span class="toc-number">1.2.0.5.</span> <span class="toc-text">5、设置程序运行的主类</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#6%E3%80%81%E5%BC%80%E5%90%AF%E8%AE%A1%E6%97%B6%E5%99%A8"><span class="toc-number">1.2.0.6.</span> <span class="toc-text">6、开启计时器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#7%E3%80%81%E5%B0%86java-awt-headless%E8%AE%BE%E7%BD%AE%E4%B8%BAtrue"><span class="toc-number">1.2.0.7.</span> <span class="toc-text">7、将java.awt.headless设置为true</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#8%E3%80%81%E8%8E%B7%E5%8F%96%E5%B9%B6%E5%90%AF%E7%94%A8%E7%9B%91%E5%90%AC%E5%99%A8"><span class="toc-number">1.2.0.8.</span> <span class="toc-text">8、获取并启用监听器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#9%E3%80%81%E8%AE%BE%E7%BD%AE%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E5%8F%82%E6%95%B0"><span class="toc-number">1.2.0.9.</span> <span class="toc-text">9、设置应用程序参数</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#10%E3%80%81%E5%87%86%E5%A4%87%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="toc-number">1.2.0.10.</span> <span class="toc-text">10、准备环境变量</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#11%E3%80%81%E5%BF%BD%E7%95%A5bean%E4%BF%A1%E6%81%AF"><span class="toc-number">1.2.0.11.</span> <span class="toc-text">11、忽略bean信息</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#12%E3%80%81%E6%89%93%E5%8D%B0banner"><span class="toc-number">1.2.0.12.</span> <span class="toc-text">12、打印banner</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#13%E3%80%81%E5%88%9B%E5%BB%BA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%9A%84%E4%B8%8A%E4%B8%8B%E6%96%87"><span class="toc-number">1.2.0.13.</span> <span class="toc-text">13、创建应用程序的上下文</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#14%E3%80%81%E5%AE%9E%E4%BE%8B%E5%8C%96%E5%BC%82%E5%B8%B8%E6%8A%A5%E5%91%8A%E5%99%A8"><span class="toc-number">1.2.0.14.</span> <span class="toc-text">14、实例化异常报告器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#15%E3%80%81%E5%87%86%E5%A4%87%E4%B8%8A%E4%B8%8B%E6%96%87%E7%8E%AF%E5%A2%83"><span class="toc-number">1.2.0.15.</span> <span class="toc-text">15、准备上下文环境</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#16%E3%80%81%E5%88%B7%E6%96%B0%E4%B8%8A%E4%B8%8B%E6%96%87"><span class="toc-number">1.2.0.16.</span> <span class="toc-text">16、刷新上下文</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#17%E3%80%81%E5%88%B7%E6%96%B0%E4%B8%8A%E4%B8%8B%E6%96%87%E5%90%8E%E7%BD%AE%E5%A4%84%E7%90%86"><span class="toc-number">1.2.0.17.</span> <span class="toc-text">17、刷新上下文后置处理</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#18%E3%80%81%E7%BB%93%E6%9D%9F%E8%AE%A1%E6%97%B6%E5%99%A8"><span class="toc-number">1.2.0.18.</span> <span class="toc-text">18、结束计时器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#19%E3%80%81%E5%8F%91%E5%B8%83%E4%B8%8A%E4%B8%8B%E6%96%87%E5%87%86%E5%A4%87%E5%B0%B1%E7%BB%AA%E4%BA%8B%E4%BB%B6"><span class="toc-number">1.2.0.19.</span> <span class="toc-text">19、发布上下文准备就绪事件</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#20%E3%80%81%E6%89%A7%E8%A1%8C%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9A%84run%E6%96%B9%E6%B3%95"><span class="toc-number">1.2.0.20.</span> <span class="toc-text">20、执行自定义的run方法</span></a></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/06/03/SpringAOP%E5%8E%9F%E7%90%86/" title="SpringAOP原理">SpringAOP原理</a><time datetime="2024-06-03T09:11:47.000Z" title="Created 2024-06-03 17:11:47">2024-06-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/06/03/%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8%E7%9A%84%EF%BC%9F/" title="springboot究竟是如何启动的？">springboot究竟是如何启动的？</a><time datetime="2024-06-03T05:42:42.000Z" title="Created 2024-06-03 13:42:42">2024-06-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/11/30/IOStream/" title="IOStream">IOStream</a><time datetime="2023-11-30T01:59:17.000Z" title="Created 2023-11-30 09:59:17">2023-11-30</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/11/29/JavaIO/" title="JavaIO">JavaIO</a><time datetime="2023-11-29T14:20:58.000Z" title="Created 2023-11-29 22:20:58">2023-11-29</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/10/30/hello-world/" title="Hello World">Hello World</a><time datetime="2023-10-30T01:46:17.000Z" title="Created 2023-10-30 09:46:17">2023-10-30</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By 小亚</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="Toggle Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between Single-column and Double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="Back To Top"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script src="/js/foot.js"></script><script src="/js/jquery.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="true"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"jsonPath":"/live2dw/assets/tororo.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>